home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 May / PCWorld_2007-05_cd.bin / komunikace / bitcomet / bitcomet_setup.exe / $0 / extensions / {19503e42-ca3c-4c27-b1e2-9cdb2170ee34} / install.js < prev    next >
Text File  |  2007-03-07  |  4KB  |  109 lines

  1. const APP_DISPLAY_NAME = "FlashGot";
  2. const APP_NAME = "flashgot";
  3. const APP_PACKAGE = "/informaction/flashgot";
  4. const APP_VERSION = "0.5.98.070302";
  5.  
  6. const APP_PREFS_FILE="defaults/preferences/flashgot.js";
  7. const APP_XPCOM_SERVICE="components/flashgotService.js";
  8. const APP_JAR_FILE = "flashgot.jar";
  9. const APP_CONTENT_FOLDER = "content/flashgot/";
  10. const APP_LOCALES = [
  11.   "it-IT","th-TH","de-DE","nl-NL", 
  12.   "ru-RU","es-ES","es-AR", "es-CL", // "ms-MY",
  13.   "hu-HU", "sv-SE","fr-FR", "fi-FI",
  14.   "he-IL","tr-TR","sr-YU", "ca-AD",
  15.   "zh-TW","zh-CN","el-GR", "uk-UA",
  16.   "lt-LT","ja-JP","pl-PL", "hr-HR",
  17.   "id-ID","cs-CZ","ko-KR", "be-BY",
  18.   "nb-NO","ro-RO","sk-SK",
  19.   "fa-IR","sl-SI","ar-JO",
  20.   "bg-BG","da-DK","pt-BR",
  21.   "pt-PT","sq-AL","en-US"
  22.   ];
  23.  
  24. const APP_SUCCESS_MESSAGE = APP_DISPLAY_NAME+" should now be available on the context menu when you restart Mozilla.";
  25.  
  26. const INST_TO_PROFILE = "Do you wish to install "+APP_DISPLAY_NAME+" to your profile?\nThis will mean it does not need reinstalling when you update Mozilla.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the Mozilla directory.)";
  27.  
  28.  
  29. var instToProfile = true;
  30.  
  31. myPerformInstall(false);
  32.  
  33. function myPerformInstall(secondTry) {
  34.   
  35.   var err;
  36.   initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
  37.   
  38.   if(!secondTry) {  
  39.     // profile installs only work since 2003-03-06
  40.     instToProfile = (buildID>2003030600 && confirm(INST_TO_PROFILE));
  41.   }
  42.   
  43.   var chromef = instToProfile ? getFolder("Profile", "chrome") : getFolder("chrome");
  44.   err = addFile(APP_PACKAGE, APP_VERSION, "chrome/" + APP_JAR_FILE, chromef, null);
  45.   
  46.   if(APP_PREFS_FILE && (err == SUCCESS) ) {
  47.     const prefDirs=[
  48.       getFolder(getFolder("Profile"),"pref"),
  49.       getFolder(getFolder(getFolder("Program"),"defaults"),"pref")
  50.       ];
  51.     for(var j=prefDirs.length; j-->0;) {
  52.       var prefDir=prefDirs[j];
  53.       if(!File.exists(prefDir)) {
  54.         File.dirCreate(prefDir);
  55.       }
  56.       err = addFile(APP_PACKAGE, APP_VERSION,  APP_PREFS_FILE, prefDir, null, true);
  57.       logComment("Adding "+APP_PREFS_FILE+" in "+prefDir+": exit code = "+err);
  58.     }
  59.   }
  60.   
  61.   if(err == SUCCESS) {
  62.     var jar = getFolder(chromef, APP_JAR_FILE);
  63.     const chromeFlag=instToProfile?PROFILE_CHROME:DELAYED_CHROME;
  64.   
  65.     registerChrome(CONTENT | chromeFlag, jar, APP_CONTENT_FOLDER);
  66.     var localesCount=APP_LOCALES.length;
  67.     if(localesCount>0) {
  68.       registerChrome(LOCALE | chromeFlag, jar, "content/flashgot/"+APP_LOCALES[--localesCount]+"/");
  69.       while(localesCount-- >0) {
  70.         registerChrome(LOCALE  | chromeFlag, jar, "locale/"+APP_LOCALES[localesCount]+"/flashgot/");
  71.       }
  72.     }
  73.     registerChrome(SKIN | chromeFlag, jar, "skin/classic/flashgot/");
  74.     
  75.     
  76.     if(APP_XPCOM_SERVICE) {
  77.       var componentsDir = getFolder("Components");
  78.       addFile(APP_PACKAGE,APP_VERSION, APP_XPCOM_SERVICE, componentsDir, null, true);
  79.       addFile(APP_NAME, "components/.autoreg", getFolder("Program"), "");
  80.     }
  81.     
  82.     err = performInstall();
  83.     if(err == -239 && !secondTry) {
  84.       alert("Chrome registration problem, maybe transient, retrying...");
  85.       cancelInstall(err);
  86.       myPerformInstall(true);
  87.       return;
  88.     }
  89.     if(err == SUCCESS || err == 999) {
  90.       alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\n"+APP_SUCCESS_MESSAGE);
  91.     } else {
  92.       var msg = "Install failed!!! Error code:" + err;
  93.  
  94.       if(err == -239) {
  95.         msg += "\nThis specific error is usually transient:"
  96.           +"\nif you retry to install again, it will probably go away."
  97.       }
  98.  
  99.       alert(msg);
  100.       cancelInstall(err);
  101.     }
  102.   } else {
  103.     alert("Failed to create " +APP_JAR_FILE +"\n"
  104.       +"You probably don't have appropriate permissions \n"
  105.       +"(write access to your profile or chrome directory). \n"
  106.       +"_____________________________\nError code:" + err);
  107.     cancelInstall(err);
  108.   }
  109. }